import { numPositiveNumber, numPositiveLimitNinetyNine, numTwoDecimal } from '@/utils/formRules';
import { reactive } from 'vue';

//入库-预算清单
const storageInBillFiledList = reactive([
	{
		type: 'text',
		label: '一级分类',
		isDisabled: true,
		labelWidth: '100px',
		bindFieldName: 'level1Value',
		bindFieldVal: '',
		maxlength: 11,
	},
	{
		type: 'text',
		label: '二级分类',
		isDisabled: true,
		bindFieldName: 'level2Value',
		bindFieldVal: '',
	},
    {
		type: 'text',
		label: '三级分类',
		isDisabled: true,
		bindFieldName: 'level3Value',
		bindFieldVal: '',
	},
    {
		type: 'text',
		label: '清单名称',
		isDisabled: true,
		bindFieldName: 'inventoryName',
		bindFieldVal: '',
	},
]);

//入库-物料信息
const storageInSuppliesFiledList = reactive([
	{
		type: 'text',
		label: '物料名称',
		isRequired: true,
		labelWidth: '100px',
		bindFieldName: 'materielName',
		bindFieldVal: '',
		maxlength: 50,
	},
	{
		type: 'text',
		label: '规格型号',
		isRequired: true,
		bindFieldName: 'specificationType',
		bindFieldVal: '',
		maxlength: 50,
	},
    {
		type: 'text',
		label: '品牌',
		isRequired: false,
		bindFieldName: 'brand',
		bindFieldVal: '',
		maxlength: 50,
	},
    {
		type: 'select',
		label: '存放位置',
		isRequired: true,
		optionList: [],
		keyName: 'unitStoreNum',
		valName: 'name',
		bindFieldName: 'locationId',
		bindFieldTxtName: 'location',
		bindFieldVal: '',
		maxlength: 140,
	},
    {
		type: 'select',
		label: '物料类型',
		isRequired: true,
		optionList: [],
		keyName: 'dictValue',
		valName: 'dictLabel',
		bindFieldName: 'materielType',
		bindFieldVal: '',
	},
	{
		type: 'text',
		inputType: 'textarea',
		label: '物料说明',
		bindFieldName: 'materielRemark',
		bindFieldVal: '',
		maxlength: 140,
	},
    {
		type: 'file',
		label: '附件',
		isRequired: false,
		limit: 10,
		baseUrl: process.env.VUE_APP_BASE_API_ZK,
		fileSize: 1000,
		acceptType: '*',
		multiple: false,
		isDisabled: false,
		bindFieldName: 'attachmentUrlList',
		bindFieldVal: [],
	},
]);

//入库-入库信息
const storageInInfoFiledList = reactive([
    {
		type: 'text',
		label: '数量',
		isRequired: true,
		labelWidth: '100px',
		bindFieldName: 'num',
		bindFieldVal: '',
		maxlength: 18,
		rules: [{ validator: numPositiveNumber(), trigger: ['change', 'blur'] }],
	},
    {
		type: 'text',
		label: '单价',
		isRequired: true,
		bindFieldName: 'unitPrice',
		bindFieldVal: '',
		maxlength: 18,
		rules: [{ validator: numTwoDecimal(), trigger: ['change', 'blur'] }],
	},
    {
		type: 'select',
		label: '入库人员',
		placeholder: '请输入名称或手机号查询',
		isRequired: true,
		isRemote: true,
		optionList: [],
		keyName: 'userKey',
		valName: 'name',
		bindFieldName: 'warehousingPersonnel',
		bindFieldVal: '',
	},
    {
		type: 'date',
		label: '入库时间',
		isRequired: true,
		bindFieldName: 'warehousingTime',
		format: 'YYYY-MM-DD HH:mm',
		bindFieldVal: '',
	},
    {
		type: 'text',
		inputType: 'textarea',
		label: '说明',
		bindFieldName: 'warehousingRemark',
		bindFieldVal: '',
		maxlength: 140,
	},
]);

//出库
const storageOutFiledList = reactive([
	{
		type: 'text',
		label: '出库数量',
		isRequired: true,
		labelWidth: '100px',
		bindFieldName: 'outNum',
		bindFieldVal: '',
		maxlength: 18
	},
	{
		type: 'date',
		label: '出库时间',
		isRequired: true,
		labelWidth: '100px',
		inputType:"datetime",
		format: 'YYYY-MM-DD HH:mm',
		bindFieldName: 'outTime',
		bindFieldVal: '',
	},
	{
		type: 'select',
		label: '领取人',
		isRequired: true,
		isRemote: true,
		optionList: [],
		keyName: 'userKey',
		valName: 'name',
		bindFieldName: 'receiver',
		placeholder: '请输入名称或手机号查询',
		bindFieldVal: '',
	},
	{
		type: 'text',
		inputType: 'textarea',
		label: '用途',
		bindFieldName: 'purpose',
		bindFieldVal: '',
		maxlength: 140,
	},
]);

//预警
const warningFiledList = reactive([
	{
		type: 'radio',
		label: '预警开关',
		labelWidth: '100px',
		isRequired: true,
		optionList: [{key:1, label:"开启"},{key:0, label:"关闭"}],
		keyName: 'key',
		valName: 'label',
		bindFieldName: 'warnStatus',
		bindFieldVal: 0,
	},
	{
		type: 'radio',
		label: '预警规则',
		labelWidth: '100px',
		isRequired: true,
		optionList: [{key:1, label:"自定义"},{key:0, label:"库存为0提醒"}],
		keyName: 'key',
		valName: 'label',
		bindFieldName: 'warnRule',
		bindFieldVal: 0,
		reasonObj: {
			filedName: 'warnStatus',
			filedVal: [1],
		},
	},
	{
		type: 'text',
		label: '预警数量',
		isRequired: true,
		prepend: '当数量小于',
		unit: '个',
		bindFieldName: 'warnNum',
		bindFieldVal: '',
		reasonObj: {
			filedName: 'warnRule',
			filedVal: [1],
		},
		rules: [{ validator: numPositiveLimitNinetyNine(), trigger: ['change', 'blur'] }],
	},
])

export { storageInBillFiledList, storageInSuppliesFiledList, storageInInfoFiledList, storageOutFiledList, warningFiledList };
